package cn.semes.controller;

import cn.semes.User;
import cn.semes.feignclient.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @BelongsProject: springcloudnetflix-parent
 * @BelongsPackage: cn.itsource.controller
 * @Author: Director
 * @CreateTime: 2022-07-28  10:21
 * @Description: 支付服务接口
 * @Version: 1.0
 */
@RestController
@RequestMapping("/pay")
public class PayController {

    // 注入feign接口
    @Autowired
    private UserService userService;

    /*
     * @Description: 调用user服务接口并返回
     * @Author: Director
     * @Date: 2022/7/28 10:22
     * @param id: 参数Id
     * @return: cn.itsource.domain.User
     **/
    @GetMapping("/{id}")
    public User getById(@PathVariable("id") Long id){
        // 使用openFeign调用user服务
        User user = userService.getUser(id);
        if (user.getId().equals(-1L)){
            return user;
        }
        // 这一坨是业务
        System.out.println("看看能不能进来");
        return user;
    }

}